<?php
namespace app\index\model;
use think\Db;
use think\Model;

class Attentions extends Model
{
	//添加关注
    public static function attentionSet(){
    	 $activity=Db::name('activity')
    	           ->field('id as activity_id,name,time_from,time_to,location,price,enroll_num,display_member_id')
    	           ->select();
    	 foreach ($activity as $key => $value) {
    	           $userList= Db::name('user_info')->field('userPhone,nickname')
    	           ->where('uid','in',$value['display_member_id'])
    	           ->select();
    	           $activity[$key]['userList']=$userList;
    	           }          
         return $activity;
    }
    //查询关注
    public static function attentionSel($uid,$nearby_id){
         $user_relation=Db::name('user_relation')
                   ->field('uid,follow_uid')
                   ->where(['uid'=>$uid,'follow_uid'=>$nearby_id])
                   ->find();
         return $user_relation;
    }
    //查询Ta是不是我的粉丝
    public  static  function MyFans($uid,$nearby_id){
      $fensSet=Db::name('user_relation')
                   ->where(['uid'=>$uid,'fans_uid'=>$nearby_id])
                   ->find();
         return $fensSet;  
    }
    //查询Ta关注我
    public static function fansSel($nearby_id,$uid){
         $user_fens=Db::name('user_relation')
                   ->where(['uid'=>$uid,'fans_uid'=>$nearby_id])
                   ->find();
         return $user_fens;
    }
    //判断Ta添加我成为Ta的粉丝
    public  static  function neaFans($uid,$nearby_id){
      $fensSet=Db::name('user_relation')
                   ->where(['uid'=>$nearby_id,'fans_uid'=>$uid])
                   ->find();
         return $fensSet;  
    }
    //查询关注的领队
    public static function captainSel($uid,$captain_id){
         $user_captain=Db::name('user_captain')
                   ->where(['uid'=>$uid,'captain_id'=>$captain_id])
                   ->find();
         return $user_captain; 
    }

}   